<template>
  <div class="operation-space-tool-bar">
    <el-icon>
      <read-book :strokeWidth="2" />
    </el-icon>
    <el-icon>
      <full-screen v-if="!isFullscreen" @click="enter" :strokeWidth="2" />
      <off-screen v-else @click="exit" :strokeWidth="2" />
    </el-icon>
    <el-icon @click="viewAiming">
      <aiming :strokeWidth="2" />
    </el-icon>
    <div class="zoom-operation">
      <el-icon
        style="margin-right: 8px"
        @click="
          () => {
            setZoom(2, -1)
          }
        "
      >
        <minus :strokeWidth="2" />
      </el-icon>
      <el-slider
        size="small"
        :model-value="zoom * 100"
        :step="2"
        :min="70"
        :max="150"
        style="width: 100px; --n-rail-height: 2px; --n-handle-size: 14px"
        :format-tooltip="(value: number) => `${value}%`"
        @input="(x) => setZoom(x)"
      />
      <el-icon
        style="margin-left: 8px"
        @click="
          () => {
            setZoom(2, 1)
          }
        "
      >
        <plus :strokeWidth="2" />
      </el-icon>
      <span class="echo">{{ (zoom * 100).toFixed(0) + '%' }}</span>
    </div>
    <el-icon>
      <help :strokeWidth="2" />
    </el-icon>
  </div>
</template>

<script setup lang="ts">
import { Aiming, FullScreen, Help, Minus, OffScreen, Plus, ReadBook } from '@icon-park/vue-next'
import { useFullscreen } from '@vueuse/core'

const props = defineProps({
  zoom: {
    type: Number,
    required: true
  },
  viewAiming: {
    type: Function,
    required: false,
    default: () => {}
  },
  setZoom: {
    type: Function,
    required: false,
    default: () => {}
  }
})

const { isFullscreen, enter, exit } = useFullscreen()
</script>
<style scoped lang="scss">
.operation-space-tool-bar {
  height: 40px;
  background-color: white;
  border: 1px solid rgba(100, 100, 100, 0.3);
  box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.2);
  padding: 0 15px;
  display: flex;
  align-items: center;
  border-radius: 5px;

  .el-icon {
    font-size: 20px;
    cursor: pointer;
    margin: 0 5px;
  }

  .el-icon:hover {
    color: var(--el-color-primary);
  }

  .zoom-operation {
    display: flex;
    align-items: center;
    font-size: 12px;

    .echo {
      width: 35px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .el-slider {
      --el-slider-border-radius: 1.5px;
      --el-slider-height: 3px;
      --el-slider-button-size: 15px;
      --el-slider-button-wrapper-size: 18px;
      --el-slider-button-wrapper-offset: -7.5px;
    }
  }
}
</style>
